
const mysql = require('mysql2');

//sqlite mongodb   sequelize

const config={
  host     : 'localhost',
  user     : 'root',
  password: '123456',
  database : 'tododb',
  port:'3306'
}
const pool = mysql.createPool(config)


async function execSql(sql, sqlParams) {
    const mypromise = new Promise((resolve, reject) => {
        pool.getConnection((err, connection) => {
            if (err) {
                return reject(err)
            }
            connection.query(sql, sqlParams, function (err, result) {
                if (err) {
                    reject(err)
                    return
                }

                resolve(result)
            })

            connection.release()

        }) 
     
    })
    const result = await mypromise

 
    return result
}
module.exports = {
    pool,execSql
}